<div id="venue_<?php echo $venueIndex; ?>_batch_<?php echo $batchIndex; ?>_earlydiscount">
    <?php
    $earlyBirdDiscount = ClassEarlyDiscount::model()->findAllByAttributes(array('class_batch_id' => $batchId));
    $earlyIndex = '';
    if (!empty($earlyBirdDiscount)) {
        for ($earlyIndex = 0; $earlyIndex < count($earlyBirdDiscount); $earlyIndex ++) {
            $discount = '';
            $inPercentage = '';
            $validTo = '';
            $discount = $earlyBirdDiscount[$earlyIndex]->discount_price;
            $inPercentage = $earlyBirdDiscount[$earlyIndex]->in_percentage;
            $validTo = $earlyBirdDiscount[$earlyIndex]->valid_to;
            ?>
            <div id="venue_<?php echo $venueIndex; ?>_batch_<?php echo $batchIndex; ?>_earlyCount_<?php echo $earlyIndex; ?>">
                <div class="sm-col-2 addmarginB20">
                    <div class="common"> 
                        <div class="colEarly col1">
                            <input onblur="checkValueEmpty(this.id);" onchange="enableDisableEarlyBirdTextField(this.id);" name="ClassEarlyDiscount[ClassVenue][<?php echo $venueIndex ?>][ClassBatch][<?php echo $batchIndex; ?>][discount_price][]" id="class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_discount_price_<?php echo $earlyIndex; ?>" type="text" placeholder="Discount Price" onkeypress="return isNumberKey(event)" class="<?php echo ($inPercentage != '') ? '' : 'requiredfield'; ?> field small" value="<?php echo $discount; ?>">
                            <div class="errorMessage" id="error_class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_discount_price_<?php echo $earlyIndex; ?>" style="display:none">Discount price is required.</div>
                        </div>

                        <div class="colEarly col2">
                            <input onblur="checkValueEmpty(this.id);" onchange="enableDisableEarlyBirdTextField(this.id);" name="ClassEarlyDiscount[ClassVenue][<?php echo $venueIndex ?>][ClassBatch][<?php echo $batchIndex; ?>][in_percentage][]" id="class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_in_percentage_<?php echo $earlyIndex; ?>" type="text" placeholder="In Percentage" onkeypress="return isNumberKey(event)" class="<?php echo ($discount != '') ? '' : 'requiredfield'; ?> field small"  value="<?php echo $inPercentage; ?>">
                            <div class="errorMessage" id="error_class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_in_percentage_<?php echo $earlyIndex; ?>" style="display:none">Percentage is required.</div>
                        </div>

                        <div class="colEarly col2">
                            <input name="ClassEarlyDiscount[ClassVenue][<?php echo $venueIndex ?>][ClassBatch][<?php echo $batchIndex; ?>][valid_to][]" id="class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_valid_to_<?php echo $earlyIndex; ?>" class="hasDatepicker requiredfield  field small" onkeyup="hasDatepicker(this.id);" onclick="hasDatepicker(this.id);" onpaste="return false;" onblur="checkValueEmpty(this.id)" type="text" placeholder="Valid To" readonly="readonly" size="10" value="<?php echo $validTo; ?>">
                            <div class="errorMessage" id="error_class_venue_<?php echo $venueIndex ?>_classbatch_<?php echo $batchIndex; ?>_early_valid_to_<?php echo $earlyIndex; ?>" style="display:none">Valid to is required.</div>
                        </div>

                        <div class="colEarlylast col2">
                            <a href="javascript:void(0)" id="venue_<?php echo $venueIndex ?>_batch_<?php echo $batchIndex; ?>_earlyRemove_<?php echo $earlyIndex; ?>" onclick="removeEarlyDiscount(this.id);">-Remove</a></div>
                        <div class="clear"></div>
                    </div>            
                </div>
            </div>
            <?php
        }
    }
    ?>
</div>
<div class="clear"></div>
<div class="common">
    <p class="alignL remmarginB"><a href="javascript:void(0)" id="venue_<?php echo $venueIndex; ?>_batch_<?php echo $batchIndex; ?>_earlydiscount_<?php echo ($earlyIndex == '') ? '0' : $earlyIndex - 1; ?>" onclick="addEarlyDiscount(this.id);">+ Add Early Discounts</a></p>
</div>